package com.xbongbong.saas.service;

import com.alibaba.fastjson.JSONArray;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.pojo.FieldAttrEntityForImport;
import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.pojo.dto.ImportFormDataDTO;
import com.xbongbong.paas.pojo.dto.SaasFormSaveDTO;
import com.xbongbong.paas.pojo.dto.ValidateDataDTO;
import com.xbongbong.paas.pojo.imports.CellTitlePojo;
import com.xbongbong.paas.pojo.imports.RowGroupPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.costadjust.dto.CostAdjustDeleteBatchDTO;
import com.xbongbong.pro.costadjust.dto.CostAdjustEditAttrUpdateDTO;
import com.xbongbong.pro.costadjust.dto.CostAdjustUpdateBatchDTO;
import com.xbongbong.pro.costadjust.vo.CostAdjustDeleteBatchVO;
import com.xbongbong.pro.formexplain.pojo.dto.HandlerExplainInLinkItemDTO;
import com.xbongbong.pro.product.pojo.dto.PagingProductDTO;
import com.xbongbong.pro.product.pojo.vo.PagingProductVO;
import com.xbongbong.saas.domain.entity.ext.CostAdjustEntityExt;

import java.util.List;

/**
 * @author WuHB
 * @date 2021/11/23 17:01
 */
public interface CostAdjustService {

    /**
     * 成本调整单保存前saas特殊校验
     *
     * @param validateDataDTO saas特殊校验数据入参
     * @throws XbbException 业务异常
     */
    void beforeSave(ValidateDataDTO validateDataDTO) throws XbbException;

    /**
     * 成本调整单保存后逻辑
     *
     * @param saasFormSaveDTO saas保存数据
     * @throws XbbException 业务异常
     */
    void afterSave(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;


    /**
     * 成本调整单产品保存
     *
     * @param productArray 产品数组
     * @param corpid       公司id
     * @param costAdjustId 对应入库单的id
     * @param formId       表单ID
     * @param isWorkflow   是否工作流
     * @throws XbbException 业务异常
     */
    void saveProduct(JSONArray productArray, String corpid, Long costAdjustId, Long formId, boolean isWorkflow) throws XbbException;

    /**
     * 获取分页产品
     *
     * @param pagingProductDTO pagingProductDTO
     * @return 分页产品
     * @throws XbbException 异常
     */
    PagingProductVO getPagingProduct(PagingProductDTO pagingProductDTO) throws XbbException;

    void afterSaveForWorkflow(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    /**
     * 批量删除成本调整单的数据
     *
     * @param costAdjustDeleteBatchDTO 成本调整单批量删除
     * @return 成本调整单批量删除
     * @throws XbbException 异常
     */
    CostAdjustDeleteBatchVO deleteBatch(CostAdjustDeleteBatchDTO costAdjustDeleteBatchDTO) throws XbbException;


    /**
     * 批量编辑某个字段
     *
     * @param attrUpdateDTO 编辑的字段信息
     * @throws XbbException 异常
     */
    void batchEditAttr(CostAdjustEditAttrUpdateDTO attrUpdateDTO) throws XbbException;

    /**
     * 批量更新
     *
     * @param updateBatchDTO 修改实体
     * @throws XbbException 异常
     */
    void updateBatch(CostAdjustUpdateBatchDTO updateBatchDTO) throws XbbException;

    /**
     * 将Excel数据格式化成表单保存需要的JSON格式的数据
     *
     * @param importFormDataDTO 导入入参
     * @param titlePojoList     标题
     * @param rowGroupPojo      一个表单对应的一组Excel填写的数据
     * @param fieldAttrList     解释
     * @return FormDataAddDTO
     * @throws XbbException XbbException
     */
    FormDataAddDTO formatExcelValue(ImportFormDataDTO importFormDataDTO, List<CellTitlePojo> titlePojoList, RowGroupPojo rowGroupPojo, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    /**
     * 格式化导出值
     *
     * @param paasFormDataESList 数据
     * @throws XbbException 异常
     */
    void formatExportValue(List<PaasFormDataEntityExt> paasFormDataESList, FormDataListDTO formDataListDTO, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    CostAdjustEntityExt getEntityById(Long dataId , String corpid) throws XbbException;

    /**
     * 关联新建时格式化解释
     *
     * @param handlerExplainInLinkItemDTO 关联新建表单解释的参数dto
     * @throws XbbException 异常
     */
    void formatLinkAddExplain(HandlerExplainInLinkItemDTO handlerExplainInLinkItemDTO) throws XbbException;

    /**
     * 工作流保存之后的操作
     *
     * @param saasFormSaveDTO 表单信息
     * @throws XbbException 异常
     */
    void afterSaveForUpdateWorkflow(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;
}
